<?php

function genlinktacpham($matp) {
    echo base_url("index.php/product/detail?matp=" . $matp);
}

function genlinktacgia($matg, $tentg) {
    echo "Tác giả: <a href='" . base_url('index.php/tacgia/?matg=' . $matg) . "'>  $tentg </a>";
}

function genlinknxb($manxb, $tennxb) {
    echo "Nhà xuất bản: <a href='" . base_url('index.php/nxb/?manxb=' . $manxb) . "'>  $tennxb </a>";
}
?>
<div class="wrapper-row">

    <!-- hien thi danh sach san pham :3 san pham / 1 hang -->
    <?php
    // var_dump($tacgias);
    $count = 0;
    echo "<section>";
    $x = 1;
    foreach ($products as $row) {
        $hinhanh = $row['HINHANH'];
        $giaban = $row["GIABAN"];
        $matp = $row["MATP"];
        if ($count % 3 == 0)
            echo "</section> <section class='row'>"; $count+=1;
        ?>
        <figure class="span4 s-product">
            <div class="s-product-img">
                <a href="<?php genlinktacpham($matp); ?> ">
                    <img src="<?= base_url("public/tacpham/" . $hinhanh); ?>" alt=""></img>
                </a>

            </div>
            <article class="s-product-det">
                <h3><a href="<? genlinktacpham($matp) ?>">MãTP: <span class="matp"><?= $row['MATP'] ?></span><span class="tentp">  <?= $row['TENTP']; ?></span> </a></h3>
                <!--<div class="caption"> <p></p> </div>-->
                <div class="tacgia"> <p><?php genlinktacgia($tacgias[$x]["MATG"], $tacgias[$x]['TENTG']); ?></p> </div>
                <div class="nxb"> <p><?php genlinknxb($nxbs[$x]["MANXB"], $nxbs[$x]['TENNXB']); ?></p> </div>
                <div class="cart-price">
                    <span href="#" class="cart-btn2  add_to_cart"></span>
                    <span class="price"><?= $giaban; ?></span>
                </div>
            </article>

        </figure>
        <?php
        $x+=1;
    }
    ?>
    <section>             
        <!--end section row -->